export default class gameSceneUI extends Laya.Script {
    constructor() { super(); }
    private rank_btn:Laya.Button
    private select_btn:Laya.Button
    private sound_btn:Laya.Button
    private again_btn:Laya.Button         //重新开始
    private UI_panel:Laya.Sprite          //萝卜计数
    private aniDuration:number            //Tween动画时长
    
    onEnable(): void {
         //初始化变量
         this.initParams()
         //入场动画
         this.enterAni()
         //初始化绑定事件
         this.initEvent()
    }

    /**绑定点击事件 */
    initEvent(){
       //给排行榜按钮绑定事件
       this.rank_btn.on(Laya.Event.CLICK,this,this.onRank)
       //给排行榜按钮绑定事件
       this.select_btn.on(Laya.Event.CLICK,this,this.onSelect)
       //给排行榜按钮绑定事件
       this.sound_btn.on(Laya.Event.CLICK,this,this.onSound)
       //给排行榜按钮绑定事件
       this.again_btn.on(Laya.Event.CLICK,this,this.onAgain)
    }

    /**打开场景 */
    onRank(){
        Laya.Scene.open("rank_scene.scene")
    }
    onSelect(){
        Laya.Scene.open("select_scene.scene")
    }
    onSound(){
        
    } 
    onAgain(){
        //重置面板，重新开始游戏
        Laya.Scene.open("gameScene1.scene")
    }

    /**入场动画 */
    enterAni(){
        Laya.Tween.from(
            this.rank_btn,
            {y:-30},
            this.aniDuration,
            Laya.Ease.strongInOut
        )
        Laya.Tween.from(
            this.select_btn,
            {y:-500},
            this.aniDuration,
            Laya.Ease.strongInOut
        )
        Laya.Tween.from(
            this.again_btn,
            {y:-1000},
            this.aniDuration,
            Laya.Ease.strongInOut
        )
        Laya.Tween.from(
            this.sound_btn,
            {y:-1500},
            this.aniDuration,
            Laya.Ease.strongInOut
        )
        Laya.Tween.from(
            this.UI_panel,
            {y:-1000},
            this.aniDuration,
            Laya.Ease.strongInOut
        )
    }

    /**初始化变量 */
    initParams(){
         //动画时长 
         this.aniDuration=800
         //获取排行榜按钮节点
         this.rank_btn=this.owner.getChildByName('rank_btn')as Laya.Button
         //获取选择关按钮节点
         this.select_btn=this.owner.getChildByName('select_btn')as Laya.Button
         //获取再来一次
         this.again_btn=this.owner.getChildByName('again_btn')as Laya.Button
         //获取声音节点
         this.sound_btn=this.owner.getChildByName('voice_btn')as Laya.Button
         //获取声音节点
         this.UI_panel=this.owner.getChildByName('UI_panel')as Laya.Button
    }

   
    onDisable(): void {
    }
}